package com.gtw.modules.base.controller;

import com.gtw.common.utils.R;
import com.gtw.modules.base.service.TbDistrictService;
import com.gtw.modules.entity.TbDistrict;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/** 区域Controller
 * Created by wuye on 2018/1/26.
 */
@RestController
@RequestMapping("/locl/district")
public class TbDistrictController {

    @Autowired
    private TbDistrictService tbDistrictService;

    /**
     * 根据城市ID查询
     * @param cityid
     * @return
     */
    @GetMapping("/findByCityId")
    public R findByCityId(@RequestParam("cityid") int cityid){
        List<TbDistrict> list = tbDistrictService.findByCityId(cityid);
        return R.ok().put("list",list);
    }

    /**
     * 根据区域ID查询
     * @param districtid
     * @return
     */
    @GetMapping("/findByDistrictId")
    public R findByDistrictId(@RequestParam("districtid") int districtid){
        TbDistrict tbDistrict = tbDistrictService.findByDistrictId(districtid);
        return R.ok().put("tbDistrict",tbDistrict);
    }
}
